home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2.sit / Raven 1.2 / Source / Foundation / OS / ZDialogUtils.h < prev    next >
Text File  |  1997-08-07  |  4KB  |  111 lines

  1. /*
  2.  *  File:       ZDialogUtils.h
  3.  *  Summary:       Handy dialog manager related routines.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996-1997 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <2>     8/05/97    JDJ        DoNote, DoCaution, and DoStop use StandardAlert in OS 8.
  12.  *                                    Added DoSave and DoRevert.
  13.  *         <1>     5/06/96    JDJ        Created
  14.  */
  15.  
  16. #pragma once
  17.  
  18. #include <Dialogs.h>
  19.  
  20. #include <String.h>
  21.  
  22. #include <ZGeometry.h>
  23. #include <ZTypes.h>
  24.  
  25.  
  26. //-----------------------------------
  27. //    Constants
  28. //
  29. const ResID kMessageDlogID      = 130;
  30. const ResID kSaveChangesAlert   = 131;
  31. const ResID kConfirmRevertAlert = 133;
  32.  
  33. const short kSaveBtn     = 1;
  34. const short kCancelBtn   = 2;
  35. const short kDontSaveBtn = 3;
  36.  
  37.  
  38. // ===================================================================================
  39. //    Standard Filter
  40. // ===================================================================================
  41. pascal Boolean     DefaultFilter(DialogPtr dptr, EventRecord* event, short* item);    
  42.                 // Default dialog filter. Walks a list of filters until one of them handles the
  43.                 // event.
  44.  
  45. pascal Boolean     DefaultYDFilter(DialogPtr dptr, EventRecord* event, short* item, void* myData);    
  46.                 // Default standard file dialog filter. Walks a list of filters until one of 
  47.                 // them handles the event.
  48.  
  49. void            AddDialogFilter(ModalFilterProcPtr filter);
  50.                 // Adds a new dialog filter to be executed by DefaultFilter. Called by higher 
  51.                 // level components of Raven to, for example, allow windows to be updated.
  52.         
  53. pascal Boolean     DefaultFilterProc(DialogPtr dptr, EventRecord* event, short* item);    
  54.                 // The dialog filter DefaultFilter starts with. Outlines the default
  55.                 // button, handles cut/copy/paste, changes the cursor to an i-beam,
  56.                 // and handles return/escape/etc.
  57.     
  58. pascal Boolean     SaveChangesFilter(DialogPtr dptr, EventRecord* event, short* item);
  59.                 // Used by DoSave.
  60.  
  61. // ===================================================================================
  62. //    Alerts
  63. // ===================================================================================
  64. short         DoAlert(ResID id, ModalFilterProcPtr filter = DefaultFilter);
  65.  
  66. short         DoNote(const string& errorStr, const string& supplementalStr, ResID id = kMessageDlogID, ModalFilterProcPtr filter = DefaultFilter);
  67.             // Under OS 8 StandardAlert is used so errorStr appears in bold and id is
  68.             // ignored.
  69.  
  70. short         DoCaution(const string& errorStr, const string& supplementalStr, ResID id = kMessageDlogID, ModalFilterProcPtr filter = DefaultFilter);
  71.  
  72. short         DoStop(const string& errorStr, const string& supplementalStr, ResID id = kMessageDlogID, ModalFilterProcPtr filter = DefaultFilter);
  73.             
  74. short         DoSave(const string& fileName, ModalFilterProcPtr filter = SaveChangesFilter);
  75.             // Returns kSaveBtn, kCancelBtn, or kDontSaveBtn.
  76.  
  77. bool         DoRevert(const string& fileName, ModalFilterProcPtr filter = DefaultFilter);
  78.             // Returns true if the file should be reverted.
  79.  
  80. // ===================================================================================
  81. //    Accessors
  82. // ===================================================================================
  83. TRect         GetItemBounds(DialogPtr dialog, short item);
  84.             
  85. short         GetItemType(DialogPtr dialog, short item);
  86.             
  87. bool         ItemIsEnabled(DialogPtr dialog, short item);
  88.  
  89. ControlHandle GetControl(DialogPtr dialog, short item);
  90.  
  91. string         GetDStr(DialogPtr dialog, short item);
  92.  
  93. // ===================================================================================
  94. //    User Procs
  95. // ===================================================================================
  96. void         SetUserProc(DialogPtr dialog, short item, UserItemUPP userProc);
  97.             // Sets the draw proc for a user item.
  98.  
  99. void         SetDashedLineProc(DialogPtr dialog, short item);
  100.  
  101. void         SetDrawPictProc(DialogPtr dialog, short item, PicHandle* pict);
  102.             // Note that this will not work with multiple picts in a single dialog.
  103.  
  104. // ===================================================================================
  105. //    Misc
  106. // ===================================================================================
  107. void         SetDStr(DialogPtr dialog, short item, const string& str);
  108.             
  109. void        FlashButton(DialogPtr dialog, short item);
  110.             // Call this when a button is pressed via a keystroke.
  111.